New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resource API v1.0 #93
Conversation
This is the version currently on https://gist.github.com/DavidS/430330ae43ba4b51fe34bd27ddbe4bc7
This works for puppet resource and puppet apply.
* describe required call sequences * note the uniqueness requirements of status reporting per resource instance * use is/should for old and new attribute values
To make the transition easier, this version re-uses existing language as far as possible.
Returning a hash was intended to protect against duplicate resources, but it is a hassle to implement, and duplicate resources at this point were never an issue in the first place.
Could this be merged with a big 'Draft - under discussion' disclaimer ? (If need be on a separate branch) That way, others can make PR's against the draft to amend it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a few comments… i think i'm still overwhelmed with the amount of stuff here…
language/resource-api/apt_key.rb
Outdated
docs: 'Additional options to pass to apt-key\'s --keyserver-options.', | ||
}, | ||
fingerprint: { | ||
type: 'String', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this then be String[40]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. I'll change it to Pattern[/[a-f0-9]{40}/]
, as this read-only attribute will always have a specific form. Same for the next two.
language/resource-api/apt_key.rb
Outdated
read_only: true, | ||
}, | ||
expiry: { | ||
# TODO: should be DateTime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
language/resource-api/apt_key.rb
Outdated
read_only: true, | ||
}, | ||
type: { | ||
type: 'String', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enum[rsa, dsa, ecc, ecdsa]
language/resource-api/apt_key.rb
Outdated
[ | ||
"apt_key { #{values[:name].inspect}: ", | ||
] + values.keys.select { |k| k != :name }.collect { |k| " #{k} => #{values[k].inspect}," } + ['}'] | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this feels very clear and logical, but the rest up there just reads like boilerplate…
what am i missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole file is a mixture of example and prototype library code, I've added an explanation at the top:
# This is a experimental hardcoded implementation of what will be come the Resource API's runtime
# environment. This code is used as test-bed to see that the proposal is technically feasible.
the simpleapt.rb
is closer to what a real provider would look like.
* add explanatory text * tighten up read_only attribute types
The different kinds of attributes are mutually exclusive. Changing this to a single key makes it easier to read, and reason about.
This will make the first step to a new provider smaller, while still providing the power and flexibility if required.
To keep the loop closed, I'm currently working on a prototype implementation of this in https://github.com/DavidS/puppetlabs-apt/tree/resource-api-experiments It currently only supports listing |
Logging is the more central concept and requires explanation first. Commands can then reference the loglevels, without requiring forward references.
This has been addressed by having the provider be a plain class. Developers can use regular ruby to build that class in any way they like.
language/resource-api/README.md
Outdated
|
||
```ruby | ||
class Puppet::Provider::AptKey::AptKey | ||
def set(context, changes, noo: false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noop
b9884ed
to
c395408
Compare
Edits to spec resource-api readme
While it's not yet fully implemented, I'd like to call for a final round of comments on the text as it stands. A 0.9 of the core concepts is available as https://rubygems.org/gems/puppet-resource_api and is already being trialled by us internally. |
See `pdk new provider` and https://github.com/puppetlabs/pdk-templates/tree/master/object_templates provider*.erb for live examples.
PS: see also |
The Resource API v1.0 gem has been released, so this is now a Thing[tm]. |
Public PR to facilitate conversations.
This contains draft spec language, code examples, and the history how we got here.
There is still much to do before this can be merged.